package top.rish.rib.base.service;


import org.beetl.sql.solon.annotation.Db;
import org.noear.solon.annotation.Component;
import org.noear.solon.data.annotation.Cache;

@Component
public class DictTranslatorService {

    @Db
    DictTranslatorMapper dictTranslatorMapper;

    static final int CACHE_TIME = 60;

    @Cache(service =  "rib_local_cache",
            key ="translator:dict:${dict}:${value}",
            seconds = CACHE_TIME)
    public String getLabelFromDictTable(
             String dict, String key, String label,Object value) {
        String ret = dictTranslatorMapper.getLabelFromDictTable(dict,key,label,value);
        return ret == null ? "" : ret;
    }

    @Cache(service = "rib_local_cache",
            key ="translator:table:${table}:${key}:${label}:${value}",
            seconds = CACHE_TIME)
    public String getLabelFromBizTable(
            String table,  String key, String label,Object value) {
        String ret = dictTranslatorMapper.getLabelFromBizTable(table,key,label,value);
        return ret == null ? "" : ret;
    }

}
